package com.ln.dm1102.demo04;

import java.util.concurrent.*;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/11/2 16:26
 */
public class TestCallable02 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        Future<Integer> submit = executorService.submit(new MyCallable02());
        executorService.shutdown();
        System.out.println(submit.get());
    }
}
class MyCallable02 implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        int a=0;
        for (int i = 1; i < 101; i++) {
            a+=i;
        }
        return a;
    }
}
